import sys

from PySide6.QtCore import QUrl, QJsonDocument
from PySide6.QtWebEngineCore import QWebEngineUrlRequestInterceptor, QWebEnginePage
from PySide6.QtWebEngineWidgets import QWebEngineView
from PySide6.QtWidgets import QApplication


class WebEngineUrlRequestInterceptor(QWebEngineUrlRequestInterceptor):

    def interceptRequest(self, info):
        url = 'https://degree.qingshuxuetang.com/sias/Svc/GetCoursewareTree'
        if url in info.requestUrl().toString():
            print(info.httpHeaders().items())


if __name__ == '__main__':
    app = QApplication(sys.argv)
    view = QWebEngineView()
    page = QWebEnginePage()
    page.load(QUrl("https://www.qingshuxuetang.com/Login"))
    t = WebEngineUrlRequestInterceptor()
    page.setUrlRequestInterceptor(t)
    view.setPage(page)
    view.resize(600, 400)
    view.show()
    sys.exit(app.exec())
